$(function () {

    $('#dropdownMenu1').click(function () {
      let num=$('#numofplan').val();
      let money=$('#howmuch').val();
      let value = $('input[name="optionsRadiosinline"]').filter(":checked").val();
       $.ajax({
           url:"/user/showplan",
           type:"post",
           data:{"num":num,"money":money,"value":value},
           dataType:"json",
           success:function (info) {
               if (info!=null){
                   let lis="";
                   let sumMoney=0;
                   let sumInterest=0;
                   for(let repay of info){
                       let pMoney=Math.round( repay.pMoney*100)/100;
                       let pInterest=Math.round(repay.pInterest*100)/100;
                       let pPrincipal=Math.round( repay.pPrincipal*100)/100;
                       sumMoney+=repay.pMoney;
                       sumInterest+=repay.pInterest;
                       lis+="<li style='font-size: 17px'>"+repay.pRepaymentTime+" 还款"+pMoney+"（本金"+pPrincipal+"，综合利息"+pInterest+"元)</li>"
                   }

                   sumMoney= Math.round(sumMoney*100)/100;
                   sumInterest= Math.round(sumInterest*100)/100;
                 /*  sumMoney=sumMoney.toFixed(2);*/
                  /* sumInterest=sumInterest.toFixed(2);*/


                   $('#repayPlans').html(lis);
                   $('#message').html("<h3 style='font-size: 25px'>按日计息</h3><h3 style='font-size: 20px;'>还款总额（元）</h3>" +
                       "<h3 style='font-size: 20px;'>"+sumMoney+"元</h3><h3 style='font-size: 20px;' th:text='日利率${session.userMessage.dateRate}'%></h3>" +
                       "<h3 style='font-size: 20px;'>总综合利息 "+sumInterest+"元</h3>");
               }
           }


       })




    })

})
